package main

import "log"

func main() {
	reverseString([]byte{'1', '2', '3', '4', '5', '6', '7'})
}

// 反转字符串
//输入：["H","a","n","n","a","h"]
//输出：["h","a","n","n","a","H"]

func reverseString(s []byte) {
	le := len(s)
	if le%2 == 0 {
		for i := 0; i < le/2-1; i++ {
			s[i], s[le-i-1] = s[le-i-1], s[i]
		}
	} else {
		for i := 0; i < le/2; i++ {
			s[i], s[le-i-1] = s[le-i-1], s[i]
		}
	}
	log.Printf("%s", s)
}
